package me.itsoo.artemis.framework.repository.interceptor;

import lombok.Getter;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * Invocation
 *
 * @author zxy
 * @version 0.0.1
 * @since 2023/5/23
 */
public class Invocation {

    @Getter
    private final Object proxy;

    @Getter
    private final Method method;

    @Getter
    private final Object[] args;

    private final MethodProxy invoker;

    public Invocation(Object proxy, Method method, Object[] args, MethodProxy invoker) {
        this.proxy = proxy;
        this.method = method;
        this.args = args;
        this.invoker = invoker;
    }

    /**
     * invoke
     *
     * @return Object
     * @throws Throwable Throwable
     */
    public Object proceed() throws Throwable {
        return invoker.invoke(proxy, args);
    }
}
